package com.jsmile.cloud.accountcenter.account.repo;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jsmile.cloud.accountcenter.account.dao.AccountInfoDao;
import com.jsmile.cloud.accountcenter.account.model.AccountInfo;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 龚亮
 * @version 1.0
 * @desc 为了薪资破万，还是睡一会儿吧...!
 * @date 2020年06月04日 04:38:37
 */
@Service
@Slf4j
@Transactional(readOnly = false, rollbackFor = Exception.class)
@AllArgsConstructor
public class AccountInfoRepository extends ServiceImpl<AccountInfoDao, AccountInfo> {

    private final MemberRepository memberRepository;

    public Boolean register(AccountInfo accountInfo) {
        if (null != accountInfo.getMember()) {// 保存并更新会员
            memberRepository.saveOrUpdate(accountInfo.getMember());
        }
        return this.saveOrUpdate(accountInfo);
    }

}
